#ifndef _BARTER_SERVER_CASHIERBACKEND_H_
#define _BARTER_SERVER_CASHIERBACKEND_H_

#include "IBackEndModule.h"
#include "IDatabase.h"

/*
	When declaring a set of event hook IDs keep in mind that we are using a 32-bit event ID. This allows for ~4 billion (binary: 1024/k) different event IDs.
	To limit clashing event IDs with random traffic, modules must adhere to the following event ID guidelines:	
		4 bytes: 0xaabbccdd
			aa: Always FF
			bb: Module ID
			cc: Event page
			dd: Specific module event ID (full range: [0,255])
	Modules are allowed 32768 events before needing to use additional Module ID event space.
*/
enum CashierBackendEvents
{
	CashierBackendEvent_ItemInfo                   = 0xFF800001, // Module ID: 80, Event ID: 01
	CashierBackendEvent_ValidateInfo               = 0xFF800002, // Event ID: 02
	CashierBackendEvent_ProcessTransactionItems    = 0xFF800004, // Event ID: 04
	CashierBackendEvent_ProcessTransactionPayment  = 0xFF800010, // Event ID: 10
	CashierBackendEvent_ProcessTransactionPayCash  = 0xFF800008, // Event ID: 11
	CashierBackendEvent_ProcessTransactionPayCard  = 0xFF800008, // Event ID: 12
	CashierBackendEvent_ProcessTransactionPayCheck = 0xFF800008, // Event ID: 13
	CashierBackendEvent_Error                      = 0xFF8000FF, // Event ID: FF
};

class CashierBackend : public IBackEndModule
{
private:
	Handle<DBInstance> DBHandler;
	NetworkMessage GetItemInfo(NetworkMessage&);
	NetworkMessage ValidateInfo(NetworkMessage&);
	NetworkMessage ProcessTransItems(NetworkMessage&);
	NetworkMessage ProcessTransPayCash(NetworkMessage&);
	NetworkMessage ProcessTransPayCard(NetworkMessage&);
	NetworkMessage ProcessTransPayCheck(NetworkMessage&);
public:
	CashierBackend();
	~CashierBackend();
	void Init(Handle<DBInstance>);
	NetworkMessage OnEvent(unsigned long, NetworkMessage);
};

#endif // _BARTER_SERVER_CASHIERBACKEND_H_
